﻿package com.net.http.helper;

import java.util.Random;

public class BlowfishUtils {
	

	public static  String getBlowFish(){
		return getBlowFish(16,255);
	}
	
	public static  String getBlowFish(int minlength,int maxlength){
		Random rd = new Random();
		int length = 0;
		while(length<minlength){
			length = rd.nextInt(maxlength);
		}
		StringBuffer  buf = new StringBuffer(length);
		char a = 'a';
		for(int index = 0;index <length;index++){
			buf.append(a+rd.nextInt(26));
		}
		return buf.toString();
	}
	
	/**
	 * 生成票据的验证码(16-64)
	 * @return
	 */
	public static  String getBlowFishBylen(int minlength,int maxlength){
		Random rd = new Random();
		int length = 0;
		while(length<minlength){
			length = rd.nextInt(maxlength);
		}
		StringBuffer  buf = new StringBuffer(length);
		char a = 'a';
		for(int index = 0;index <length;index++){
			buf.append((char)(a+rd.nextInt(26)));
		}
		return buf.toString();
	}
}